from aiogram import F, Router, types
from aiogram.filters import Command, CommandStart
from aiogram.fsm.context import FSMContext
from aiogram.fsm.state import any_state

from src.bot.keyboards.reply import menu_kb
from src.bot.states import TestSG

common_router = Router()


@common_router.message(CommandStart(), any_state)
@common_router.message(Command("cancel"), any_state)
@common_router.message(F.text == "Вернуться в меню ◀️", any_state)
@common_router.callback_query(F.data == "exit", any_state)
async def start(message: types.Message | types.CallbackQuery, state: FSMContext):
    await state.clear()
    if isinstance(message, types.CallbackQuery):
        await message.message.delete()
        await message.message.answer("Главное меню", reply_markup=menu_kb())
    else:
        await message.answer("Главное меню", reply_markup=menu_kb())
